<?php
declare (strict_types=1);

namespace longhu\exceptions;

use longhu\Utils;
use think\exception\HttpException;
use Exception;

class BaseException  extends HttpException
{
    protected const HTTP_SUCCESS = 200;
    public function __construct($message, $replace = [], $code = 0, Exception $previous = null)
    {
        if (is_array($message)) {
            $errInfo = $message;
            $message = $errInfo[1] ?? '未知错误';
            if ($code === 0) {
                $code = $errInfo[0] ?? 400;
            }
        }
        if (is_numeric($message)) {
            $code = $message;
            $message = Utils::getLang($message, $replace);
            dump($message);exit;
        }

        parent::__construct($message, $code, $previous);
    }
    public function getStatusCode()
    {
        return self::HTTP_SUCCESS;
    }


}